# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Baptiste Jonglez <archlinux at bitsofnetworks dot org>

_pkgname=antlr4
pkgname="python-${_pkgname}"
pkgver=4.13.1
pkgrel=1
pkgdesc="ANTLR4 runtime for Python"
arch=('any')
url="https://www.antlr.org/"
license=('BSD')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools-scm')
checkdepends=('python-tests' 'gdb' 'tk')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/antlr/${_pkgname}/archive/${pkgver}.tar.gz")
b2sums=('a51b91ef93bd4b540a382f8d4eb2bcd1a2e47a29ab20a601a2fdc6ea3d17f9acb62a4bda1a9383ba1d40853a2346f68fe846d700c3f8ae6c9a0f940ad8c660be')

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}/runtime/Python3"
  python -m build --wheel --no-isolation
}

check() {
  cd "${srcdir}/${_pkgname}-${pkgver}/runtime/Python3"
  python -m test || echo 'Test fails due to deprecated distutils'
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}/runtime/Python3"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -d "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm644 "${srcdir}/${_pkgname}-${pkgver}"/LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}"/LICENSE
}
